<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Login Form with floating placeholder and light button</title>
    <link rel="stylesheet" href="css/style.css" />
  </head>
  <body>
    <div class="login-box">
      <h2>注册</h2>
      <form>
        <div class="user-box">
          <input
            class="my_phone"
            type="text"
            name=""
            required=""
            placeholder="电话"
          />
        </div>
        <div class="user-box">
          <input type="password" name="" required="" placeholder="验证码" />
          <label for="">4399</label>
        </div>
        <div class="user-box">
          <input
            class="my_password"
            type="password"
            name=""
            required=""
            placeholder="密码"
          />
        </div>
        <div class="user-box">
          <input
            type="password"
            name=""
            required=""
            placeholder="确认密码"
            class="my_password-s"
          />
        </div>
        <a href="#" id="login_go">
          <span></span>
          <span></span>
          <span></span>
          <span></span>
          注册并登录
        </a>
      </form>
    </div>
  </body>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.9.1/jquery.js"></script>
  <script>
    $("#login_go").click(function () {
      let text_word = $(".my_phone").val();
      let password = $(".my_password").val();
      let password_s = $(".my_password-s").val();

      if (password === password_s) {
        $.post(
          "http://localhost:3000/login",
          { text_word, password },
          function (req, res) {
            if (res == "success") {
              // 将账号密码存入
              localStorage.phone = text_word;
              // localStorage.password = password;
              console.log("登陆成功");
              location.href = "主页.html";
            } else {
              console.log("登录失败");
            }
          }
        );
      }
    });
  </script>
</html>
